package com.it.controller;

import com.alibaba.fastjson.JSON;
import com.it.domain.ResponseResult;
import com.it.service.TreeHoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/treeHole")
public class TreeHoleController {

    @Autowired
    private TreeHoleService treeHoleService;

    /**
     * 添加树洞
     * @param content
     * @return
     */
    @PostMapping("/auth/addTreeHole")
    public ResponseResult addTreeHole(@RequestBody String content) {
        content = JSON.parseObject(content).getString("content");
        content = content.substring(1,content.length()-1);
        return treeHoleService.addTreeHole(content);
    }

    /**
     * 查看树洞
     * @return
     */
    @GetMapping("/getTreeHoleList")
    public ResponseResult getTreeHoleList() {
        return treeHoleService.getTreeHole();
    }

}
